This guide walks you through setting up a custom terminal command called shutdownmac
that gracefully closes all open applications on your Mac and then shuts it down. It's especially useful if you want a clean exit and don’t want to lose unsaved work.
Open Terminal and run:
nano ~/shutdownmac
Then paste the following into the file:
#!/bin/bash # Gracefully quit all user-facing apps osascript <
Ctrl + O
then Enter
to saveCtrl + X
to exitchmod +x ~/shutdownmac
echo 'alias shutdownmac="$HOME/shutdownmac"' >> ~/.zprofile
Then reload your terminal profile:
source ~/.zprofile
Now you can just type shutdownmac
in your terminal and it will: